﻿package lobby
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.net.NetConnection;
	import flash.events.NetStatusEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.Responder;
	import lobby.events.LobbyEvent;
	import lobby.common.Utility;
	import lobby.constants.ConstData;
	import flash.utils.*;
	
	/**
	 * ...
	 * @author Bamboo
	 */
	public class ConnectFMS extends EventDispatcher
	{
		private var _connectGame:NetConnection;
		private var _clientObject:Object;
		
		private var _fmsPath:String;
		private var _userType:String;
		private var _userId:String;
		private var _userPassword:String;
		private var _betLtdSeq:String;
		private var _sessionId:String;
		private var _lang:String;
		private var _versionNo:String;
		private var _forceReload:String;
		private var _isMain:String;
		private var _siteName:String;
		private var _ncName:String;
		private var _ip:String;
		private var _countryCode:String;
		private var _loginTypeID:String;
		private var _parentSID:String;
		private var _keno:String;
		private var _getWellComeMessage:int;		
		private var _roomId:String = "0";
		private var _casinoID:String = "0";
		
		public function ConnectFMS()
		{
			_connectGame = new NetConnection();
			_clientObject = new Object();
		}
		
		//define flash media server path
		public function set setFmsPath(value:String):void
		{
			this._fmsPath = value;
		}
		
		public function get getFmsPath():String
		{
			return this._fmsPath;
		}
		
		//define roomid
		public function set setRoomId(value:String):void
		{
			this._roomId = value;
		}
		
		public function get getRoomId():String
		{
			return this._roomId;
		}
		
		// define user type
		public function set setUserType(value:String):void
		{
			this._userType = value;
		}
		
		public function get getUserType():String
		{
			return this._userType;
		}
		
		//define user id
		public function set setUserId(value:String):void
		{
			this._userId = value;
		}
		
		public function get getUserId():String
		{
			return this._userId;
		}
		
		//define user password
		public function set setUserPassword(value:String):void
		{
			this._userPassword = value;
		}
		
		public function get getUserPassword():String
		{
			return this._userPassword;
		}
		
		//define BetLtdSeq
		public function set setBetLtdSeq(value:String):void
		{
			this._betLtdSeq = value;
		}
		
		public function get getBetLtdSeq():String
		{
			return this._betLtdSeq;
		}
		
		//define Session id
		public function set setSessionId(value:String):void
		{
			this._sessionId = value;
		}
		
		public function get getSessionId():String
		{
			return this._sessionId;
		}
		
		//define language
		public function set setLanguage(value:String):void
		{
			this._lang = value;
		}
		
		public function get getLanguage():String
		{
			return this._lang;
		}
		
		//define Version Number
		public function set setVersionNo(value:String):void
		{
			this._versionNo = value;
		}
		
		public function get getVersionNo():String
		{
			return this._versionNo;
		}
		
		//define ForceReload
		public function set setForceReload(value:String):void
		{
			this._forceReload = value;
		}
		
		public function get getForceReload():String
		{
			return this._forceReload;
		}
		
		//define isMain
		public function set setIsMain(value:String):void
		{
			this._isMain = value;
		}
		
		public function get getIsMain():String
		{
			return this._isMain;
		}
		
		//define site Name
		public function set setSiteName(value:String):void
		{
			this._siteName = value;
		}
		
		public function get getSiteName():String
		{
			return this._siteName;
		}
		
		//defin casino Id
		public function set setCasinoId(value:String):void
		{
			this._casinoID = value;
		}
		
		public function get getCasinoId():String
		{
			return this._casinoID;
		}
		
		//define ncName
		public function set setNcName(value:String):void
		{
			this._ncName = value;
		}
		
		public function get getNcName():String
		{
			return this._ncName;
		}
		
		//define ip
		public function set setIp(value:String):void
		{
			this._ip = value;
		}
		
		public function get getIp():String
		{
			return this._ip;
		}
		
		//define country code
		public function set setCountryCode(value:String):void
		{
			this._countryCode = value;
		}
		
		public function get getCountryCode():String
		{
			return this._countryCode;
		}
		
		//define  type login id
		public function set setLoginTypeId(value:String):void
		{
			this._loginTypeID = value;
		}
		
		public function get getLoginTypeId():String
		{
			return this._loginTypeID;
		}
		
		//define parentSID
		public function set setParentSID(value:String):void
		{
			this._parentSID = value;
		}
		
		public function get getParentSID():String
		{
			return this._parentSID;
		}
		
		//define keno game
		public function set setKeno(value:String):void
		{
			this._keno = value;
		}
		
		public function get getKeno():String
		{
			return this._keno;
		}
		
		//do connect FMS
		public function getConnect():void
		{
			
			_clientObject["setAllTableRoutesbyTable_Bac"] = setAllTableRoutesbyTable;
			_clientObject["setAllTableRoutesbyTable_Dice"] = setAllTableRoutesbyTable;
			_clientObject["setAllTableRoutesbyTable_DT"] = setAllTableRoutesbyTable;
			_clientObject["setAllTableRoutesbyTable_SD"] = setAllTableRoutesbyTable;
			_clientObject["setAllTableRoutesbyTable_RO"] = setAllTableRoutesbyTable;
			_clientObject["setAllTableRoutesbyTable_FT"] = setAllTableRoutesbyTable;
			_clientObject["setSessionToken"] = setSessionToken;
			_clientObject["setTableListByAccount_Lobby"] = setTableListByAccount;
			_clientObject["setErrorMessage"] = memberSetErrorMessage;
			_clientObject["setRecentBet"] = setRecentBet;
			_clientObject["setServerDate"] = setServerDate;
			_clientObject["setMemberWinLose"] = setMemberWinLose;
			_clientObject["setTransactionReport"] = setTransactionReport;
			_clientObject["setTransactionRpt"] = setDetailTransactionRpt;
			_clientObject["setNewsMessage"] = setNewsMessage;
			_clientObject["setMemberInfo"] = setMemberInfo;
			_clientObject["setMemberLimit"] = setMemberLimit;
			_clientObject["checkSpecialMember"] = checkSpecialMember;
			_clientObject["setAccInfoByUserN"] = setAccInfoByUserN;
			_clientObject["showPasswordResult"] = showPasswordResult;
			_clientObject["setListDepWithVen"] = setListDepWithVen;
			_clientObject["setDepWithVenReport"] = setDepWithVenReport;
			_clientObject["setHotLineGame"] = setHotLine;
			_clientObject["sendStatusGame"] = sendStatusGame;
			/*
			   _clientObject["setBetStatus"] = setBetStatus;
			   _clientObject["checkRoom"] = checkRoom;
			   _clientObject["setEmperorUserBalance"] = setEmperorUserBalance;
			   _clientObject["setEmperorLoginKey"] = setEmperorLoginKey;
			   _clientObject["setEmperorDeposit"] = setEmperorDeposit;
			   _clientObject["setEmperorWithdraw"] = setEmperorWithdraw;
			   _clientObject["setMGSAccInfo"] = setMGSAccInfo;
			   _clientObject["setMGSCreatePokerAccount"] = setMGSCreatePokerAccount;
			   _clientObject["setMGSWithdraw"] = setMGSWithdraw;
			   _clientObject["setMGSDeposit"] = setMGSDeposit;
			   _clientObject["getClosedTables"] = GetClosedTables;
			   _clientObject["showResult"] = showResult;
			   _clientObject["countSession"] = countSession;
			   _clientObject["setAllVODId"] = setAllVODId;
			   _clientObject["setAllVODIdbyGroup"] = setAllVODIdbyGroup;
			   _clientObject["setTableLimit"] = setTableLimit;
			   _clientObject["heartBeat"] = heartBeat;
			   _clientObject["setAcctypeUser"] = setAcctypeUser;
			   _clientObject["setAllowVendorGame"] = setAllowVendorGame;
			   _clientObject["setExRateVenMb"] = setExRateVenMb;
			   _clientObject["setBetStatusChangeLang"] = setBetStatusChangeLang;
			   _clientObject["setGetMGSBalance"] = setGetMGSBalance;
			   _clientObject["setListShowMBVen"] = setListShowMBVen;
			   _clientObject["setVendorBalance"] = setVendorBalance;
			   _clientObject["setChangeMGSPokerPass"] = setChangeMGSPokerPass;
			   _clientObject["setTransaction"] = setTransaction;
			   _clientObject["setAccountBalance"] = setAccountBalance;
			   _clientObject["setBetDetailDes"] = setBetDetailDes;
			 */
			_clientObject["logMeOut"] = logMeout;
			
			_connectGame.client = _clientObject;
			_connectGame.connect(("rtmp://" + this.getFmsPath + "/" + this.getRoomId), this.getUserType, this.getUserId, this.getUserPassword, this.getBetLtdSeq, this.getSessionId, this.getLanguage, this.getVersionNo, this.getForceReload, this.getIsMain, this.getSiteName, this.getCasinoId, this.getNcName, this.getIp, this.getCountryCode, this.getLoginTypeId, this.getParentSID, this.getKeno);
			
			_connectGame.addEventListener(NetStatusEvent.NET_STATUS, netStatusNcIdHdl);
			_connectGame.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHdl);
		}
		
		private function sendStatusGame(instanceName, gameType , statusGame):void 
		{
			trace(instanceName, gameType, statusGame);
			if (statusGame == "NewGameset") {
				
				var e:LobbyEvent = new LobbyEvent(LobbyEvent.DELETE_HISTORY, true);
				e.tableId = instanceName;
				dispatchEvent(e);
			}
		}
		
		private function setHotLine(result:String):void 
		{			
			result = result.substr(1, (result.length - 1));
			GlobalVariables.hotLinemsg = result;
			dispatchEvent(new LobbyEvent(LobbyEvent.SET_HOTLINE_MSG, true));
		}
		
		public function getBetStatusN(tbId:String):void
		{
			this._connectGame.call("getBetStatusN", new Responder(successCallFMS, failCallFMS), tbId, this._sessionId, "setBetStatusN");
		}
		
		private function setBetStatus(result:String, tbId:String):void
		{
			trace("tbId:" + tbId, "setBetStatus:" + result);
		}
		
		public function getBetStatus(tbId:String):void
		{
			this._connectGame.call("getBetStatus", new Responder(successCallFMS, failCallFMS), tbId, this._sessionId);
		}
		
		public function getServerDate():void
		{
			this._connectGame.call("getServerDate", new Responder(successCallFMS, failCallFMS), _sessionId);
		}
		
		public function getTransactionReport(page:uint, numRecord:uint, dateFrom:String, dateTo:String):void
		{
			trace("_sessionId : " + _sessionId + " :" + dateFrom + " : " + dateTo + " : " + _userId + " : " + GlobalVariables.lang + " : " + page + " : " + numRecord);
			this._connectGame.call("getTransactionReport", new Responder(successCallFMS, failCallFMS), _sessionId, dateFrom, dateTo, _userId, GlobalVariables.lang, page, numRecord);
		}
		
		public function setTransactionReport(result):void
		{
			trace("setTransactionReport : " + result + " : " + Utility.checkResult(result));
						
			var e:LobbyEvent;
			if (Utility.checkTokenInvalid(result))
			{
				e = new LobbyEvent(LobbyEvent.INVALID_TOKEN, true);
				e.ms = result.substr(1, result.length);
				dispatchEvent(e);
			}
			else if (Utility.checkResult(result))
			{
				e = new LobbyEvent(LobbyEvent.SET_TRANSACTION_REPORT, true);
				e.result = result;
				dispatchEvent(e);
			}
			else
			{
				e = new LobbyEvent(LobbyEvent.SHOW_MS, true);
				e.ms = result.substr(ConstData.POS_FAILT_RESULT, e.result.length);
				dispatchEvent(e);
			}
			
		}
		public function getTransferReport(dateFrom:String, dateTo:String, vendor:String, page:uint,numRecord:uint):void
		{
						
			trace("_sessionId : " + _sessionId + " :" + dateFrom + " : " + dateTo + " : " + _userId + " : " + vendor);
			this._connectGame.call("getDepWithVenReport", new Responder(successCallFMS, failCallFMS), _sessionId, dateFrom, dateTo, _userId, vendor, page, numRecord);
		}
		
		public function setDepWithVenReport(result):void
		{
			//trace("settransfer : " + result + " : " + Utility.checkResult(result));
			if (Utility.checkResult(result))
			{
				var e:LobbyEvent = new LobbyEvent(LobbyEvent.SET_TRANSACTION_REPORT, true);
				e.result = result;
				dispatchEvent(e);
			}
		}
		
		public function getDetailTransactionRpt(page:uint):void
		{
			//ncId.call("getTransactionReportDetail",  new Responder(successCallFMS, failCallFMS), stageInfo.userInfo.sessionId, String(e.ms), GlobalVariables.lang);
			this._connectGame.call("getTransactionReportDetail", new Responder(successCallFMS, failCallFMS), _sessionId, page, GlobalVariables.lang);
		}
		
		public function setDetailTransactionRpt(result:String):void
		{
			trace("setDetailTransactionRpt : " + result + " : " + Utility.checkResult(result))
			var e:LobbyEvent;		
			if (Utility.checkTokenInvalid(result))
			{
				e = new LobbyEvent(LobbyEvent.INVALID_TOKEN, true);
				e.ms = result.substr(1, result.length);
				dispatchEvent(e);
			}
			else if (Utility.checkResult(result))
			{
				e = new LobbyEvent(LobbyEvent.SET_TRANSACTION_REPORT_DETAIL, true);
				e.result = result;
				dispatchEvent(e);
			}
			else
			{
				e = new LobbyEvent(LobbyEvent.SHOW_MS, true);
				e.ms = result.substr(ConstData.POS_FAILT_RESULT, e.result.length);
				dispatchEvent(e);
			}
		}
		
		public function getHistoryByTable(tbId:String, gameType:String):void
		{
			switch (gameType)
			{
				case ConstData.GAME_TYPE_BAC: 
				case ConstData.GAME_TYPE_BAC_IN: 
					this._connectGame.call("getAllTableRoutesbyTable_Bac", new Responder(successCallFMS, failCallFMS), this._sessionId, tbId);
					break;
				case ConstData.GAME_TYPE_DT: 
					this._connectGame.call("getAllTableRoutesbyTable_DT", new Responder(successCallFMS, failCallFMS), this._sessionId, tbId);
					break;
				case ConstData.GAME_TYPE_SICBO: 
					this._connectGame.call("getAllTableRoutesbyTable_Dice", new Responder(successCallFMS, failCallFMS), this._sessionId, tbId);
					break;
				case ConstData.GAME_TYPE_SEDIE: 
					this._connectGame.call("getAllTableRoutesbyTable_SD", new Responder(successCallFMS, failCallFMS), this._sessionId, tbId);
					break;
				case ConstData.GAME_TYPE_FANTAN: 
					this._connectGame.call("getAllTableRoutesbyTable_FT", new Responder(successCallFMS, failCallFMS), this._sessionId, tbId);
					break;
				case ConstData.GAME_TYPE_ROULETTE: 
					this._connectGame.call("getAllTableRoutesbyTable_RO", new Responder(successCallFMS, failCallFMS), this._sessionId, tbId);
					break;
			
			}
		
		}
		
		private function setServerDate(result:String):void
		{
			trace("phan loai : " + GlobalVariables.functionCallByGameDetail);
			if (GlobalVariables.functionCallByGameDetail == "gameHistoryBtn")
			{
				var e:LobbyEvent = new LobbyEvent(LobbyEvent.UPDATE_HISTORY_DATE, true);
				e.result = result;
				dispatchEvent(e);
			}
			else if (GlobalVariables.functionCallByGameDetail == "transactionReportBtn" || GlobalVariables.functionCallByGameDetail == "trasferReportBtn")
			{
				var e1:LobbyEvent = new LobbyEvent(LobbyEvent.UPDATE_REPORT_DATE, true);
				e1.result = result;
				dispatchEvent(e1);
			}
		}
		
		private function checkSpecialMember(pResult:String):void
		{
			GlobalVariables.IsMemberSpecial = pResult;
		}
		
		/**
		 * @author	Tom
		 * @param	result
		 */
		private function setMemberWinLose(result:String):void
		{
			//trace("setMemberWinLose:" + result);
			var e:LobbyEvent;
			if (Utility.checkTokenInvalid(result))
			{
				e = new LobbyEvent(LobbyEvent.INVALID_TOKEN, true);
				e.ms = result.substr(1, result.length);
				dispatchEvent(e);
			}
			else if (Utility.checkResult(result))
			{
				e = new LobbyEvent(LobbyEvent.UPDATE_HISTORY, true);
				e.result = result;
				dispatchEvent(e);
			}
			else
			{
				e = new LobbyEvent(LobbyEvent.SHOW_MS, true);
				e.ms = result.substr(ConstData.POS_FAILT_RESULT, e.result.length);
				dispatchEvent(e);
			}
		}
		
		/**
		 * @author	Tom
		 * @param	dateFrom
		 * @param	dateTo
		 */
		public function getMemberWinLose(dateFrom:String, dateTo:String):void
		{
			this._connectGame.call("getMemberWinLose", new Responder(successCallFMS, failCallFMS), _sessionId, dateFrom, dateTo);
		}
		
		/**
		 * @author	Tom
		 * @param	result
		 */
		public function setRecentBet(result:String):void
		{
			var e:LobbyEvent
			//trace("setRecentBet" + result);
			if (Utility.checkTokenInvalid(result))
			{
				e = new LobbyEvent(LobbyEvent.INVALID_TOKEN, true);
				e.ms = result.substr(1, result.length);
				dispatchEvent(e);
			}
			else
			{
			var temp:Array = result.split("&");
			if (Utility.checkResult(temp[1]))
			{
					e  = new LobbyEvent(LobbyEvent.UPDATE_BET_STATUS, true);
				e.result = result;
				dispatchEvent(e);
			}
				
		}
		}
		
		/**
		 * @author	Tom
		 * @param	roomId
		 * @param	page
		 * @param	numRecord
		 */
		public function getRecentBet(roomId:String, page:uint, numRecord:uint):void
		{
			this._connectGame.call("getRecentBet", new Responder(successCallFMS, failCallFMS), roomId, _sessionId, GlobalVariables.lang, page, numRecord);
		}
		
		private function memberSetErrorMessage(result:String):void
		{
			trace("memberSetErrorMessage:" + result);
			var e:LobbyEvent = new LobbyEvent(LobbyEvent.SHOW_MS, true);
			e.ms = result;
			dispatchEvent(e);
		}
		
		/**
		 * @author	Tom
		 * @param	result
		 */
		private function setAllTableRoutesbyTable(result:String):void
		{
			var e:LobbyEvent;
			if (Utility.checkTokenInvalid(result))
			{
				e = new LobbyEvent(LobbyEvent.INVALID_TOKEN, true);
				e.ms = result.substr(1, result.length);
				dispatchEvent(e);
			}
			else if (Utility.checkResult(result))
			{
				e = new LobbyEvent(LobbyEvent.SET_HISTORY, true);
				e.result = result;
				dispatchEvent(e);
			}
			else
			{
				e = new LobbyEvent(LobbyEvent.SHOW_MS, true);
				e.ms = result.substr(ConstData.POS_FAILT_RESULT, e.result.length);
				dispatchEvent(e);
			}
		}
		
		private function logMeout(result:String):void
		{
			closeConnect();
			trace("logMeout:" + result);
			var e:LobbyEvent = new LobbyEvent(LobbyEvent.SET_ERROR_MESSAGE, true);
			e.result = result;
			dispatchEvent(e);
		}
		
		private function netStatusNcIdHdl(e:NetStatusEvent):void
		{
			trace("netStatusNcIdHdl:" + e.info.code);
			var event:LobbyEvent;
			switch (e.info.code)
			{
				case "NetConnection.Connect.Success": 
					break;
				case "NetConnection.Connect.Failed": 
					event = new LobbyEvent(LobbyEvent.FAILED_LOGIN, true);
					event.result = GlobalVariables.langInfo.hashTable.lookupString("FailedLogin");
					dispatchEvent(event);
					break;
				case "NetConnection.Connect.Rejected": 
					event = new LobbyEvent(LobbyEvent.REJECTED_LOGIN, true);
					event.result = GlobalVariables.langInfo.hashTable.lookupString("RejectLogin");
					dispatchEvent(event);
					break;
				case "NetConnection.Connect.Closed": 
					break;
			}
		}
		
		/**
		 * @author Bamboo
		 */
		private function securityErrorHdl(e:SecurityErrorEvent):void
		{
			trace("SecurityErrorHdl: " + e);
		}
		
		private function setSessionToken(result:String):void
		{
			var e:LobbyEvent = new LobbyEvent(LobbyEvent.SET_SESSION_TOKEN, true);
			e.result = result;
			dispatchEvent(e);
			trace("setSessionToken:" + result);
		}
		
		private function setTableListByAccount(result:String):void
		{
			
			var e:LobbyEvent;
			if (Utility.checkTokenInvalid(result))
			{
				e = new LobbyEvent(LobbyEvent.INVALID_TOKEN, true);
				e.ms = result.substr(1, result.length);
				dispatchEvent(e);
			}
			else if (Utility.checkResult(result))
			{
				e = new LobbyEvent(LobbyEvent.SET_TABLE_LIST_BY_ACCOUNT, true);
				e.result = result.substr(ConstData.LEN_SUCCESS_RESULT, result.length);
				dispatchEvent(e);
			}
			else
			{
				e = new LobbyEvent(LobbyEvent.SHOW_MS, true);
				e.ms = result.substr(ConstData.POS_FAILT_RESULT, e.result.length);
				dispatchEvent(e);
			}
		
		}
		
		private function failCallFMS(status:Object):void
		{
			for (var p:String in status)
			{
				trace("FAIL CALL FMS:  " + p + ": " + status[p]);
			}
		}
		
		private function successCallFMS(status:Object):void
		{
		
		}
		
		public function getTableListByAccount(sessionToken:String, tablefilter:String):void
		{
			trace("getTableListByAccount", sessionToken, tablefilter);
			_connectGame.call("getTableListByAccount_Lobby", new Responder(successCallFMS, failCallFMS), sessionToken, tablefilter);
		}
		
		public function getPersonInfo(sessionToken:String):void
		{
			trace("getPersonInfo" + sessionToken);
			_connectGame.call("getPersonInfo", new Responder(successCallFMS, failCallFMS), sessionToken);
		}
		
		public function setMemberInfo(result:String):void
		{
			
			var e:LobbyEvent;
			if (Utility.checkTokenInvalid(result))
			{
				e = new LobbyEvent(LobbyEvent.INVALID_TOKEN, true);
				e.ms = result.substr(1, result.length);
				dispatchEvent(e);
			}
			else if (Utility.checkResult(result))
			{
				e = new LobbyEvent(LobbyEvent.SET_RESULT_MEMBER_INFO, true);
				e.result = result;
				dispatchEvent(e);
			}
			else
			{
				e = new LobbyEvent(LobbyEvent.SHOW_MS, true);
				e.ms = result.substr(1, result.length)
				dispatchEvent(e);
			}
		}
		
		public function getMemberLimit(sessionToken:String):void
		{
			trace("getMemberLimit");
			_connectGame.call("getMemberLimit", new Responder(successCallFMS, failCallFMS), sessionToken);
		}
		
		public function setMemberLimit(result:String):void
		{
			trace("setMemberLimit : " + Utility.checkResult(result));
			
			var e:LobbyEvent;
			if (Utility.checkTokenInvalid(result))
			{
				e = new LobbyEvent(LobbyEvent.INVALID_TOKEN, true);
				e.ms = result.substr(1, result.length);
				dispatchEvent(e);
			}
			else if (Utility.checkResult(result))
			{
				e = new LobbyEvent(LobbyEvent.SET_RESULT_MEMBER_LIMIT, true);
				e.result = result;
				dispatchEvent(e);
			}
			else
			{
				e = new LobbyEvent(LobbyEvent.SHOW_MS, true);
				e.ms = result.substr(ConstData.POS_FAILT_RESULT, e.result.length);
				dispatchEvent(e);
			}
		}
		
		public function setNewPass(oldPass, newPass):void
		{
			trace("setNewPass");
			_connectGame.call("setNewPassword", new Responder(successCallFMS, failCallFMS), _sessionId, oldPass, newPass);
		}
		
		public function callGetWelcomeMessage():void
		{
			clearTimeout(_getWellComeMessage);
			trace("callGetWelcomeMessage");
			_connectGame.call("getNews", new Responder(successCallFMS, failCallFMS), false, _sessionId, GlobalVariables.lang, _roomId);
		
		}
		
		public function setNewsMessage(result:String):void
		{
			trace("setNewsMessage:" + result);
			var e:LobbyEvent = new LobbyEvent(LobbyEvent.UPDATE_WELCOME_MESSAGE_INFO, true);
			e.result = result
			dispatchEvent(e);
			_getWellComeMessage = setTimeout(callGetWelcomeMessage, 300000);
		}
		
		public function getAccInfoByUserN(sessionToken:String, userName:String):void
		{
			trace("getMemberLimit");
			_connectGame.call("getAccInfoByUserN", new Responder(successCallFMS, failCallFMS), sessionToken, userName);
		}
		
		public function setAccInfoByUserN(result):void
		{
			var e:LobbyEvent
			if (Utility.checkTokenInvalid(result))
			{
				e = new LobbyEvent(LobbyEvent.INVALID_TOKEN, true);
				e.ms = result.substr(1, result.length);
				dispatchEvent(e);
			}
			else
			{
				var tmpArr:Array = new Array();
				tmpArr = result.split("*");
				var currency:String = tmpArr[tmpArr.length - 1];
				trace("_global.Currency :" + currency);
				e = new LobbyEvent(LobbyEvent.GET_CURRENCY_ICON, true);
				e.result = currency;
				dispatchEvent(e);
				//currencyIcon_mc.setCurrencyIncon(_global.Currency);
				//currencyIconTotal_mc.setCurrencyIncon(_global.Currency);
				//currencyIconLucky_mc.setCurrencyIncon(_global.Currency);
			}
			
			//_root.txtCurrency_txt.text =  _global.Currency;
		}
		
		public function closeConnect():void
		{
			this._connectGame.close();
		}

		public function showPasswordResult(result:String):void
		{
			trace("showPasswordResult:" + result);
			var e:LobbyEvent = new LobbyEvent(LobbyEvent.SHOW_MS, true);
			e.ms = result;
			dispatchEvent(e);
		}
		
		public function getListDepWithVen(sessionToken:String, userName:String):void
		{
			trace("sessionToken : " + sessionToken + " userName: " + userName);
			_connectGame.call("getListDepWithVen", new Responder(successCallFMS, failCallFMS), sessionToken, userName);
		}
		
		public function setListDepWithVen(pResult):void
		{
			trace("setListDepWithVen : " + pResult);
			if (pResult.substr(0, 1) == "0")
			{
				GlobalVariables.listDepWithVen = pResult.substr(2, pResult.length);
				trace("GlobalVariables.listDepWithVen : " + GlobalVariables.listDepWithVen);
			}
		}
		
		public function getHotLineMsg():void 
		{
			_connectGame.call("getHotLineGame", new Responder(successCallFMS, failCallFMS),_sessionId, GlobalVariables.lang);
		}
	}
}